package com.xr.miniprogram.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xr.common.utils.DateUtils;
import com.xr.miniprogram.domain.MiniProgramSwiper;
import com.xr.miniprogram.mapper.MiniProgramSwiperMapper;
import com.xr.miniprogram.service.IMiniProgramSwiperService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class MiniProgramSwiperServiceImpl extends ServiceImpl<MiniProgramSwiperMapper, MiniProgramSwiper> implements IMiniProgramSwiperService {
    @Autowired
    private MiniProgramSwiperMapper miniProgramSwiperMapper;

    /**
     * 查询轮播图
     *
     * @param id 轮播图主键
     * @return 轮播图
     */
    @Override
    public MiniProgramSwiper selectSwiperById(Long id)
    {
        return miniProgramSwiperMapper.selectSwiperById(id);
    }

    /**
     * 查询轮播图列表
     *
     * @param miniProgramSwiper 轮播图
     * @return 轮播图
     */
    @Override
    public List<MiniProgramSwiper> selectSwiperList(MiniProgramSwiper miniProgramSwiper)
    {
        return miniProgramSwiperMapper.selectSwiperList(miniProgramSwiper);
    }

    /**
     * 新增轮播图
     *
     * @param miniProgramSwiper 轮播图
     * @return 结果
     */
    @Override
    public int insertSwiper(MiniProgramSwiper miniProgramSwiper)
    {
        miniProgramSwiper.setCreateTime(DateUtils.getNowDate());
        return miniProgramSwiperMapper.insertSwiper(miniProgramSwiper);
    }

    /**
     * 修改轮播图
     *
     * @param miniProgramSwiper 轮播图
     * @return 结果
     */
    @Override
    public int updateSwiper(MiniProgramSwiper miniProgramSwiper)
    {
        miniProgramSwiper.setUpdateTime(DateUtils.getNowDate());
        return miniProgramSwiperMapper.updateSwiper(miniProgramSwiper);
    }

    /**
     * 批量删除轮播图
     *
     * @param ids 需要删除的轮播图主键
     * @return 结果
     */
    @Override
    public int deleteSwiperByIds(Long[] ids)
    {
        return miniProgramSwiperMapper.deleteSwiperByIds(ids);
    }

    /**
     * 删除轮播图信息
     *
     * @param id 轮播图主键
     * @return 结果
     */
    @Override
    public int deleteSwiperById(Long id)
    {
        return miniProgramSwiperMapper.deleteSwiperById(id);
    }
}
